//
//  MidouTopView.m
//  markmap
//
//  Created by 甘世清 on 2024/6/18.
//

#import "MidouTopView.h"

@implementation MidouTopView

- (void)SQ_UIViewForSelfView{
    UIImageView * bgimage = [[UIImageView alloc]init];
    bgimage.image = SQGetImage(@"midouTop");
    [self addSubview:bgimage];
    [bgimage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self).insets(UIEdgeInsetsMake(32, 16, 32, 16));
    }];
    [bgimage addSubview:self.avatarImage];
    [bgimage addSubview:self.nameLabel];
    [self.avatarImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(20);
        make.left.equalTo(bgimage).offset(24);
        make.top.equalTo(bgimage).offset(14);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.avatarImage);
        make.left.equalTo(self.avatarImage.mas_right).offset(12);
    }];
    UIImageView * douzi = [[UIImageView alloc]init];
    douzi.image = SQGetImage(@"豆子");
    [bgimage addSubview:douzi];
    [douzi mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(20);
            make.left.equalTo(bgimage).offset(24);
            make.top.equalTo(bgimage).offset(60);
    }];
    [bgimage addSubview:self.midouLabel];
    [self.midouLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(douzi);
        make.left.equalTo(douzi.mas_right).offset(12);
    }];
    
    
}
-(void)SQ_topReload{
    UserModel * model = [UserModel share];
    _midouLabel.text = [NSString stringWithFormat:@"%d %@",model.diamond,SQNSLocalString(@"觅豆")];
    [self.avatarImage.headerImage sd_setImageWithURL:SQURLImage(model.portrait) placeholderImage:SQGetImage(@"zanwutouxiang")];
    self.nameLabel.text = model.name;
}

- (HeaderView *)avatarImage{
    if (!_avatarImage) {
        _avatarImage = [[HeaderView alloc]init];
        _avatarImage.headerImage.contentMode = UIViewContentModeScaleAspectFill;
        _avatarImage.clipsToBounds = YES;
        _avatarImage.layer.cornerRadius = 10;
        _avatarImage.layer.borderColor = UIColor.whiteColor.CGColor;
        _avatarImage.layer.borderWidth = 1;
//        [_avatarImage.btn addTarget:self action:@selector(SQ_PushPeople) forControlEvents:UIControlEventTouchUpInside];
        _avatarImage.headerImage.image = SQGetImage(@"zanwutouxiang");
    }
    return _avatarImage;
}
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = FONT_MEDIUM(16);
        _nameLabel.textColor = UIColor.whiteColor;
    }
    return _nameLabel;
}

- (UILabel *)midouLabel{
    if (!_midouLabel) {
        _midouLabel = [[UILabel alloc]init];
        _midouLabel.textColor = UIColor.whiteColor;
        _midouLabel.font = FONT_SEMIBOLD(20);
    }
    return _midouLabel;
}
@end
